<?php

use yii\db\Migration;

/**
 * Handles the creation of table `package`.
 */
class m170913_054743_create_package_table extends Migration
{
    /**
     * @inheritdoc
     * @资产包基本信息表
     */
    public function up()
    {
        $this->createTable('package', [
            'id' => $this->bigPrimaryKey(),
            'code' => $this->string()->comment('编号'),
            'title' => $this->string()->notNull()->comment('名称'),
            'category' => $this->smallInteger()->notNull()->defaultValue(4)->comment('资产包类别'),//1 A自有资产包、2 B管理资产包、3 C共投共管资产包、4 D立项新包
            'type' => $this->smallInteger()->notNull()->comment('资产类型'),//1保证类2抵押类3混合类
            'access' => $this->string()->notNull()->defaultValue('0')->comment('访问权限'),//0公开、1私密（上传者系统中ID，）、2部分访问
            'access_users' => $this->string()->comment('部分访问的人的ID'),
            'creditor' => $this->string()->notNull()->comment('债权人名称'),
            'province' => $this->integer()->notNull()->comment('省份'),
            'city' => $this->integer()->notNull()->comment('城市'),
           // 'currency' => $this->smallInteger()->notNull()->comment('币种'),
            'principal' => $this->string()->notNull()->comment('本金（元）'),
            'principal_range' => $this->smallInteger()->notNull()->comment('本金额度'),//1、100万以下，2、100-1000万，3、1000-5000万，4、5000万-1亿，5、1亿以上
            'interest' => $this->string()->notNull()->comment('利息（元）'),
            'hushu' => $this->string()->notNull()->comment('户数'),
            'broke_principal' => $this->string()->comment('破产本金（元）'),
            'detail' => $this->text()->notNull()->comment('其他补充'),//详细说明
            'state' => $this->smallInteger()->notNull()->comment('状态'),//1无、2启动尽调、3已立项、4已评估、5已受让、6待跟进、
            'origin' => $this->text()->comment('渠道来源'),//1内部上传、2自动入库
            'industry' => $this->text()->comment('行业'),//项目所有行业的集合
            'owner' => $this->bigInteger()->notNull()->comment('上传人'),//默认为上传者ID，
            //'attachment' => $this->text()->notNull()->comment('清单'),//
            'limit_collection' => $this->text()->comment('未诉债权时效及催收方式'),//
            'teamwork' => $this->smallInteger()->comment('是否发起协同'),
            'created_at' => $this->dateTime()->notNull()->comment('上传时间'),//默认CURRENT_TIMESTAMP
            'updated_at' => $this->dateTime()->notNull()->comment('更新时间'),//默认CURRENT_TIMESTAMP
            'lock_user' => $this->integer()->comment('上锁用户'),
            'lock_timestamp' => $this->string()->comment('上锁时间'),
        ]);
    }

    /**
     * @inheritdoc
     */
    public function down()
    {
        $this->dropTable('package');
    }
}
